//
//  InpHealthyVC.m
//  掌上宏力
//
//  Created by admin on 2017/5/16.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "InpHealthyVC.h"
#import "InpHealthyModel.h"
#import "InptHealthyCell.h"
#import "InpatientHealthyViewModel.h"

@interface InpHealthyVC ()

@property (nonatomic,strong) InpatientHealthyViewModel *viewModel;
@end

@implementation InpHealthyVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"入院诊断";
}

-(void)getDatasArray{
    [self getDatasArray:^(NSString *page, GetDatas handler) {
        _viewModel = [[InpatientHealthyViewModel alloc] init];
        [_viewModel getInHealthyInfo:^{
            if (self.currentPage == 1) {
                handler(_viewModel.datasArray);
                [self.tableView.mj_footer endRefreshingWithNoMoreData];
            }else{
                handler([NSArray array]);
            }
        }];
    }];
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    InpHealthyModel *model = _viewModel.datasArray[section];
    NSString *dateStr = model.diagnosisDate;
    return [dateStr substringToIndex:dateStr.length-8];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    InptHealthyCell *cell = [InptHealthyCell cellWithTableView:tableView];
    cell.healthInfo = _viewModel.datasArray[indexPath.section];
    return cell;
}


@end
